import React,{Component} from 'react'
import * as api from '../../api/cart'
export default class PayProcess extends Component{
    constructor(props){
        super(props)
        this.state = {}
    }
    componentWillReceiveProps(a){
        
        if(!a.style){
            api.productCart().then((data)=>{
                let arr = data.data
                if(arr.length == 0){
                    this.refs.box.style.display = 'none'
                }else{
    
                    this.refs.box.style.display = 'block'
                }
            })
        }else{
            console.log(a.style.display)
            this.refs.box.style.display = a.style.display
        }
        
    }
    componentDidMount(){
        let index = document.getElementsByClassName('index')
        let targetEl = index[parseInt(this.props.name)]
        targetEl.style.backgroundColor = 'orange'
    }
    render(){
        return(
            <div style={{display:'block'}} ref="box">
                <div className="payPro">
                    <div>
                        <span className="index">1</span>
                        <p></p>
                        <span className="index">2</span>
                        <p></p>
                        <span className="index">3</span>  
                    </div>
                    <div>
                        <p>查看购物袋</p>
                        <p>订单确认</p>
                        <p>订单支付</p>
                    </div>
                </div>
            </div>
        )
    }
}